package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.AuditAssignee;
import com.ruoyi.system.service.IAuditAssigneeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 节点候选人（用户级）Controller
 * 
 * @author ruoyi
 * @date 2025-11-07
 */
@RestController
@RequestMapping("/system/assignee")
public class AuditAssigneeController extends BaseController
{
    @Autowired
    private IAuditAssigneeService auditAssigneeService;

    /**
     * 查询节点候选人（用户级）列表
     */
    @PreAuthorize("@ss.hasPermi('system:assignee:list')")
    @GetMapping("/list")
    public TableDataInfo list(AuditAssignee auditAssignee)
    {
        startPage();
        List<AuditAssignee> list = auditAssigneeService.selectAuditAssigneeList(auditAssignee);
        return getDataTable(list);
    }

    /**
     * 我的待审核列表
     */
    @PreAuthorize("@ss.hasPermi('system:assignee:myAssignee')")
    @GetMapping("/myAssignee")
    public TableDataInfo myAssignee(AuditAssignee auditAssignee)
    {
        startPage();
        List<AuditAssignee> list = auditAssigneeService.myAssignee(auditAssignee);
        return getDataTable(list);
    }

    /**
     * 导出节点候选人（用户级）列表
     */
    @PreAuthorize("@ss.hasPermi('system:assignee:export')")
    @Log(title = "节点候选人（用户级）", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AuditAssignee auditAssignee)
    {
        List<AuditAssignee> list = auditAssigneeService.selectAuditAssigneeList(auditAssignee);
        ExcelUtil<AuditAssignee> util = new ExcelUtil<AuditAssignee>(AuditAssignee.class);
        util.exportExcel(response, list, "节点候选人（用户级）数据");
    }

    /**
     * 获取节点候选人（用户级）详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:assignee:query')")
    @GetMapping(value = "/{auditAssigneeId}")
    public AjaxResult getInfo(@PathVariable("auditAssigneeId") Long auditAssigneeId)
    {
        return success(auditAssigneeService.selectAuditAssigneeByAssigneeId(auditAssigneeId));
    }

    /**
     * 新增节点候选人（用户级）
     */
    @PreAuthorize("@ss.hasPermi('system:assignee:add')")
    @Log(title = "节点候选人（用户级）", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AuditAssignee auditAssignee)
    {
        return toAjax(auditAssigneeService.insertAuditAssignee(auditAssignee));
    }

    /**
     * 修改节点候选人（用户级）
     */
    @PreAuthorize("@ss.hasPermi('system:assignee:edit')")
    @Log(title = "节点候选人（用户级）", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AuditAssignee auditAssignee)
    {
        return toAjax(auditAssigneeService.updateAuditAssignee(auditAssignee));
    }

    /**
     * 删除节点候选人（用户级）
     */
    @PreAuthorize("@ss.hasPermi('system:assignee:remove')")
    @Log(title = "节点候选人（用户级）", businessType = BusinessType.DELETE)
	@DeleteMapping("/{assigneeIds}")
    public AjaxResult remove(@PathVariable String[] assigneeIds)
    {
        return toAjax(auditAssigneeService.deleteAuditAssigneeByAssigneeIds(assigneeIds));
    }
}
